package com.hejing.面向对象特征之三_多态.多态的测试案例;

/**
 * ClassName: MyRectangle
 * Package: com.hejing.面向对象特征之三_多态.多态的测试案例
 * Description:
 *      矩形类
 * @Author: HeJing
 * @Create: 2023-03-26 15:49
 * @Version: 1.0
 */
public class MyRectangle extends GeometricObject{
    private double height;  // 高
    private double width;   // 宽

    public MyRectangle(String color, double weight, double height, double width) {
        super(color, weight);
        this.height = height;
        this.width = width;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }


    // 重写父类求取面积的方法
    @Override
    public double getArea() {
        System.out.println("矩形类求取面积");
        return height * width;
    }
}























